package GuessingGame;


public class GuessGame {
	
	Player p1;
	Player p2;
	Player p3;
	int x = 0;
	
	public void startGame(){
		p1 = new Player();
		p2 = new Player();
		p3 = new Player();
		x = 0;
		
		int guessp1 = 0;
		int guessp2 = 0;
		int guessp3 = 0;
		
		boolean p1isRight = false;
		boolean p2isRight = false;
		boolean p3isRight = false;
		
		int targetNum = (int) (Math.random() * 10);
		System.out.println("I'm thinking of a number between 0 and 9");
		
		while(x == 0){
			System.out.println("Number to guess is " + targetNum);
			
			p1.guess();
			p2.guess();
			p3.guess();
			
			guessp1 = p1.number;
			System.out.println("Player 1 guessed " + guessp1);
			
			guessp2 = p2.number;
			System.out.println("Player 2 guessed " + guessp2);
			
			guessp3 = p3.number;
			System.out.println("Player 3 guessed " + guessp3);
			
			if (guessp1 == targetNum){
				p1isRight = true;
			}
			if (guessp2 == targetNum){
				p2isRight = true;
			}
			if (guessp3 == targetNum){
				p3isRight = true;
			}
			
			if (p1isRight || p2isRight || p3isRight){
				System.out.println("We have a winner!");
				System.out.println("Did player 1 get it right?" + p1isRight);
				System.out.println("Did player 2 get it right?" + p2isRight);
				System.out.println("Did player 3 get it right?" + p3isRight);
				System.out.println("The game is finished");
				x = 1;
			} else {
				System.out.println("We must keep going!");
			}
			
		}
		
	}

}
